import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-04-14
 * Time: 19:46
 */
public class Test {

    public static void testInsertSort(int[] arr) {
        arr = Arrays.copyOf(arr, arr.length);
        long start = System.currentTimeMillis();
        Sort sort = new Sort();
        sort.InsertSort(arr);
        long end = System.currentTimeMillis();
        System.out.println(end - start);
    }

    public static void testShellSort(int[] arr) {
        int[] arr1 = Arrays.copyOf(arr, arr.length);
        Sort sort = new Sort();
        long start = System.currentTimeMillis();
        sort.ShellSort(arr1);
        long end = System.currentTimeMillis();
        System.out.println(end - start);
    }

    public static void testHeapSort(int[] arr) {
        arr = Arrays.copyOf(arr, arr.length);
        Sort sort = new Sort();
        long start = System.currentTimeMillis();
        sort.HeapSort(arr);
        long end = System.currentTimeMillis();
        System.out.println(end - start);
    }


    public static void main(String[] args) {
        int[] a = {9, 1, 2, 5, 7, 4, 8, 6, 3};
        System.out.println("插入排序:");
        testInsertSort(a);
        System.out.println("堆入排序:");
        testHeapSort(a);
        System.out.println("希尔排序:");
        testShellSort(a);
    }

    public static void main1(String[] args) {
        int[] a = {9, 1, 2, 5, 7, 4, 8, 6, 3};
        System.out.println(Arrays.toString(a));
        Sort sort = new Sort();
        sort.InsertSort(a);
        System.out.println(Arrays.toString(a));
    }

    public static void main2(String[] args) {
        int[] a = {9, 1, 2, 5, 7, 4, 8, 6, 3};
        System.out.println(Arrays.toString(a));
        Sort sort = new Sort();
        sort.ShellSort(a);
        System.out.println(Arrays.toString(a));
    }

    public static void main3(String[] args) {
        int[] a = {9, 1, 2, 5, 7, 4, 8, 6, 3};
        System.out.println(Arrays.toString(a));
        Sort sort = new Sort();
        sort.HeapSort(a);
        System.out.println(Arrays.toString(a));
    }
}
